package week3;

import java.util.Scanner;

public class Day4 {
    //1.字符串替换
    public String formatString (String str, char[] arg) {
        // write code here
        String[] tmp = str.split("%s");
        String s = new String();
        int k=0;
        for(String x:tmp) {
            s+=x;
            s+=arg[k++];
        }
        while(k<arg.length) {
            s+=arg[k++];
        }
        return s;
    }


    //2.神奇数
    public static void main2(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int a = in.nextInt();
            int b = in.nextInt();
            int ret = 0;//神奇数的个数
            for(int i=a;i<=b;i++) {
                if(isGodNum(i)) ret++;
            }
            System.out.println(ret);
        }
    }
    public static boolean isGodNum(int x) {//判断神奇数
        if(x<=10) return false;
        String s = new String(String.valueOf(x));//将x转成字符串
        for(int i=0;i<s.length()-1;i++) {
            String tmp = new String();
            char ch1 = s.charAt(i);
            if(ch1 == '0') continue;
            tmp+=ch1;
            for(int j=i+1;j<s.length();j++) {
                char ch2 = s.charAt(j);
                if(ch2 == '0') continue;
                tmp+=ch2;
                if(isNum(tmp)) return true;
            }
        }
        return false;
    }
    public static boolean isNum(String s) {//判断是否为质数
        int n = Integer.parseInt(s);
        for(int i=2;i<n;i++) {
            if(n%i==0) return false;
        }
        return true;
    }
    //3.
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            String s = in.nextLine();
            int n = in.nextInt();
            int left = 0;
            int right = left+4;
            int maxlen =0 ;
            String ret = new String();
            while(right<s.length()) {
                String tmp = s.substring(left,right+1);
                if(!(tmp.contains('C'+"")&&tmp.contains('G'+""))) continue;
                int len = Blength(tmp);
                if(maxlen < len ){
                    ret = tmp;//更新结果
                    maxlen = len;
                }
                left++;
                right++;
            }
            System.out.println(ret);
        }
    }
    public static int Blength(String s) {//求GC比例
        int count = 0;
        for(int i=0;i<s.length();i++) {
            char ch = s.charAt(i);
            if(ch=='G'||ch=='C') count++;
        }
        return count;
    }




}
